package com.pureut.order.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.pureut.order.dto.SysCustomDto;
import com.pureut.order.service.ISysCustomService;
import com.pureut.order.vo.SysCustomVo;
import com.sale.common.core.domain.R;
import com.sale.common.core.web.controller.BaseController;
import com.sale.common.mybatis.core.page.PageQuery;
import com.sale.common.mybatis.core.page.TableDataInfo;

import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * 客户类别
 *
 * @author Lion Li
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/custom")
public class SysCustomController extends BaseController {

    private final ISysCustomService customService;

    /**
     * 获取客户类别列表
     */
    //@SaCheckPermission("order:customer:list")
    @GetMapping("/list")
    public TableDataInfo<SysCustomDto> list(SysCustomVo custom, PageQuery pageQuery) {
        return customService.selectCustomList(custom, pageQuery);
    }

    /**
     * 新增客户类别
     */
    //@SaCheckPermission("order:customer:add")
    @PostMapping("")
    public R<Void> add(@RequestBody SysCustomVo custom) {
        return toAjax(customService.addSysCustom(custom));
    }

    /**
     * 修改客户类别
     */
    //@SaCheckPermission("order:customer:edit")
    @PutMapping("")
    public R<Void> edit(@RequestBody SysCustomVo custom) {
        return toAjax(customService.editSysCustom(custom));
    }

    /**
     * 查询单个客户类别
     */
    //@SaCheckPermission("order:customer:query")
    @GetMapping(value = "/{id}")
    public R<SysCustomDto> edit(@PathVariable Long id) {
        return R.ok(customService.viewSysCustom(id));
    }

    /**
     * 删除客户类别
     */
    //@SaCheckPermission("order:customer:remove")
    @DeleteMapping(value = "/{ids}")
    public R<Void> remove(@PathVariable Long[] ids) {
        return toAjax(customService.removeSysCustom(ids));
    }

    /**
     * 客户类别下拉列表
     */
    @GetMapping("/downList")
    public R<List<HashMap<String, String>>> downList() {
        return R.ok(customService.downList());
    }

}
